home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 2
/
Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso
/
Pearls
/
psion
/
src.doc
/
unsorted
/
opl_c
/
callc.opl
next >
Wrap
Text File
|
1984-10-28
|
935b
|
48 lines
REM CALLC.OPL
REM Example program to demonstrate calling C from OPL
REM Martin J Budden
REM October 28 1992
PROC Main:
GLOBAL CCode%(27) REM OPL.BIN is 54 bytes long
LOCAL Ret%
Ret% = Bin2Buf%:(ADDR(CCode%()),"M:\OPO\OPL.BIN")
IF Ret%
PRINT "Error opening OPL.BIN:"
PRINT ERR$(Ret%)
GET
STOP
ENDIF
Ret% = USR(ADDR(CCode%()),1,0,0,0)
PRINT "C function 1 returns",Ret%
Ret% = USR(ADDR(CCode%()),2,0,0,0)
PRINT "C function 2 returns",Ret%
Ret% = USR(ADDR(CCode%()),3,0,0,0)
PRINT "C function 3 returns",Ret%
GET
ENDP
PROC Bin2Buf%:(Addr%,File$)
REM load contents of File$ to buffer at Addr%
LOCAL Fcb%,Ret%,pBuf%
ret% = IOOPEN(Fcb%,File$,$400)
IF Ret% :RETURN Ret% :ENDIF
pBuf% = Addr%
WHILE 1
Ret% = IOREAD(Fcb%,pBuf%,512)
IF Ret%<0
IF Ret%=-36 REM EOF
Ret% = 0
ENDIF
IOCLOSE(Fcb%)
RETURN Ret%
ENDIF
pBuf% = pBuf% + Ret%
ENDWH
ENDP